<?php
	require_once("../includes/user.php");
	$user=new User(); 
	$ques_res=$user->query("select * from quiz_question_bank where test_id='$_POST[testid]'"); 
	$cnt=1;
 ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="add_qb_table">
  <tr>
    <td height="35"><div id="add_qb_status" class="strykerNotice"></div></td>
  </tr>
</table>
<script>
	$('#add_qb_table').ready(function(){
		$('#add_qb_status').html('Settings added Successfully please upload questions carefully').show(200);
	});
</script>
<?php
if($_POST['type']==2)
{
?>
<table id="ques_table" width="419" border="0" align="center" cellpadding="0" cellspacing="0">
  <?php
	while($ques_row=mysql_fetch_array($ques_res))
	{
  ?>
  	<tr>
    <td width="411">
    <div style="margin:0 auto">
    <table width="355" height="139" border="0" align="left" cellpadding="0" cellspacing="0">
      <tr>
        <td width="115" height="22" align="right" valign="top">Question : <span id="ques_up<?php echo $cnt; ?>"><?php echo $cnt; ?> </span> </td>
        <td width="240" height="22" align="left"><textarea name="question<?php echo $cnt; ?>" value="" id="question<?php echo $cnt; ?>" cols="30" rows="3"><?php echo $ques_row['ques']; ?></textarea></td>
      </tr>
      <tr>
        <td height="22" align="right">A :</td>
        <td height="22" align="left" ><input type="text" name="optone<?php echo $cnt; ?>" id="optone<?php echo $cnt; ?>" value="<?php echo $ques_row['op1']; ?>" /></td>
      </tr>
      <tr>
        <td height="22" align="right">B :</td>
        <td height="22" align="left"><input type="text" value="<?php echo $ques_row['op2']; ?>" name="opttwo<?php echo $cnt; ?>" id="opttwo<?php echo $cnt; ?>" /></td>
      </tr>
      <tr>
        <td height="22" align="right" >C :</td>
        <td height="22" align="left"><input type="text" value="<?php echo $ques_row['op3']; ?>" name="optthree<?php echo $cnt; ?>" id="optthree<?php echo $cnt; ?>" /></td>
      </tr>
      <tr>
        <td height="22" align="right">D :</td>
        <td height="22" align="left"><input type="text" name="optfour<?php echo $cnt; ?>" value="<?php echo $ques_row['op4']; ?>" id="optfour<?php echo $cnt; ?>" /></td>
      </tr>
      <tr>
        <td height="22" align="right">Ans :</td>
        <td height="22" align="left"><select name="select_answer<?php echo $cnt; ?>"  id="select_answer<?php echo $cnt; ?>">
          <option value="1"<?php if($ques_row['answer']==1)echo ' selected="selected"'; ?>>A</option>
          <option value="2"<?php if($ques_row['answer']==2)echo ' selected="selected"'; ?>>B</option>
          <option value="3"<?php if($ques_row['answer']==3)echo ' selected="selected"'; ?>>C</option>
          <option value="4"<?php if($ques_row['answer']==4)echo ' selected="selected"'; ?>>D</option>
        </select>
        </td>
      </tr>
    </table>
    </div>    
    </td>
  </tr>
   <?php
   	$cnt++;
	}
	 ?>
     <tr>
    <td width="411">
    <div style="margin:0 auto">
    <table width="355" height="139" border="0" align="left" cellpadding="0" cellspacing="0">
      <tr>
        <td width="115" height="22" align="right" valign="top">Question : <span id="ques_up<?php echo $cnt; ?>"><?php echo $cnt; ?> </span> </td>
        <td width="240" height="22" align="left"><textarea name="question<?php echo $cnt; ?>" value="" id="question<?php echo $cnt; ?>" cols="30" rows="3"></textarea></td>
      </tr>
      <tr>
        <td height="22" align="right">A :</td>
        <td height="22" align="left" ><input type="text" name="optone<?php echo $cnt; ?>" id="optone<?php echo $cnt; ?>"  /></td>
      </tr>
      <tr>
        <td height="22" align="right">B :</td>
        <td height="22" align="left"><input type="text"  name="opttwo<?php echo $cnt; ?>" id="opttwo<?php echo $cnt; ?>" /></td>
      </tr>
      <tr>
        <td height="22" align="right" >C :</td>
        <td height="22" align="left"><input type="text"  name="optthree<?php echo $cnt; ?>" id="optthree<?php echo $cnt; ?>" /></td>
      </tr>
      <tr>
        <td height="22" align="right">D :</td>
        <td height="22" align="left"><input type="text" name="optfour<?php echo $cnt; ?>"  id="optfour<?php echo $cnt; ?>" /></td>
      </tr>
      <tr>
        <td height="22" align="right">Ans :</td>
        <td height="22" align="left"><select name="select_answer<?php echo $cnt; ?>"  id="select_answer<?php echo $cnt; ?>">
          <option value="1">A</option>
          <option value="2">B</option>
          <option value="3">C</option>
          <option value="4">D</option>
        </select>
        </td>
      </tr>
    </table>
    </div>    
    </td>
  </tr>
</table>
<?php
  }
  else if($_POST['type']==1)
  {
  ?>
<table id="ques_table" width="419" border="0" align="center" cellpadding="0" cellspacing="0">
 <?php 
	while($ques_row=mysql_fetch_array($ques_res))
	{
  ?>
  <tr>
    <td width="411">
    <div style="margin:0 auto">
    <table width="355" height="44" border="0" align="left" cellpadding="0" cellspacing="0">
      <tr>
        <td width="115" height="22" align="right" valign="top">Question : <span id="ques_up<?php echo $cnt; ?>"><?php echo $cnt; ?> </span> </td>
        <td width="240" height="22" align="left"><textarea name="question<?php echo $cnt; ?>" id="question<?php echo $cnt; ?>" cols="30" rows="3"><?php echo $ques_row['ques']; ?></textarea></td>
      </tr>
      <tr>
        <td height="22" align="right">Ans :</td>
        <td height="22" align="left"><select name="select_answer<?php echo $cnt; ?>" id="select_answer<?php echo $cnt; ?>">
          <option value="1" <?php if($ques_row['answer']==1)echo 'selected="selected"'; ?>>True</option>
          <option value="2" <?php if($ques_row['answer']==2)echo 'selected="selected"'; ?>>False</option>
                  </select>
        </td>
      </tr>
    </table>
    </div>    </td>
  </tr>
    <?php
   	$cnt++;
	}
	 ?>
      <tr>
    <td width="411">
    <div style="margin:0 auto">
    <table width="355" height="44" border="0" align="left" cellpadding="0" cellspacing="0">
      <tr>
        <td width="115" height="22" align="right" valign="top">Question : <span id="ques_up<?php echo $cnt; ?>"><?php echo $cnt; ?> </span> </td>
        <td width="240" height="22" align="left"><textarea name="question<?php echo $cnt; ?>" id="question<?php echo $cnt; ?>" cols="30" rows="3"></textarea></td>
      </tr>
      <tr>
        <td height="22" align="right">Ans :</td>
        <td height="22" align="left"><select name="select_answer<?php echo $cnt; ?>" id="select_answer<?php echo $cnt; ?>">
          <option value="1">True</option>
          <option value="2">False</option>
                  </select>
        </td>
      </tr>
    </table>
    </div>    </td>
  </tr>
</table>
<?php
}
if($_POST['type']==3)
{
?>
 <table id="ques_table" width="419" border="0" align="center" cellpadding="0" cellspacing="0">
 <?php
 	 while($ques_row=mysql_fetch_array($ques_res))
	{
 ?>
  <tr>
    <td width="411">
    <div style="margin:0 auto">
    <table width="355" height="22" border="0" align="left" cellpadding="0" cellspacing="0">
      <tr>
        <td width="115" height="22" align="right" valign="top">Question : <span id="ques_up<?php echo $cnt; ?>"><?php echo $cnt; ?> </span> </td>
        <td width="240" height="22" align="left"><textarea name="question<?php echo $cnt; ?>" id="question<?php echo $cnt; ?>" cols="30" rows="3"><?php echo $ques_row['ques']; ?></textarea></td>
      </tr>
    </table>
    </div>    </td>
  </tr>
<?php
	$cnt++;
	}
 ?>
  <tr>
    <td width="411">
    <div style="margin:0 auto">
    <table width="355" height="22" border="0" align="left" cellpadding="0" cellspacing="0">
      <tr>
        <td width="115" height="22" align="right" valign="top">Question : <span id="ques_up<?php echo $cnt; ?>"><?php echo $cnt; ?> </span> </td>
        <td width="240" height="22" align="left"><textarea name="question<?php echo $cnt; ?>" id="question<?php echo $cnt; ?>" cols="30" rows="3"></textarea></td>
      </tr>
    </table>
    </div>    </td>
  </tr>
</table
  ><?php
}?>
</p>
<table width="417" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="72"><span class="smartlink" onclick="cloneInput('#ques_table')">Add new</span></td>
    <td width="345"><span class="smartlink" onclick="removeInput('#ques_table')">Delete recent</span>
      <input type="hidden" name="no_q" id="no_q" value="<?php echo mysql_num_rows($ques_res)+1;  ?>" /><input type="hidden" name="testid" id="testid" value="<?php echo $_POST['testid']; ?>"/>
    <input type="hidden" name="type" id="type" value="<?php echo $_POST['type']; ?>"/></td>
  </tr>
</table>
<table width="609" height="64" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="32" align="right">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td width="197" height="32" align="right">&nbsp;</td>
    <td width="412"><input type="image" name="next" id="next" src="img/buttons/submit.gif" onclick="edit_update_qb()" />    </td>
  </tr>
</table>
